<template>
  <!--机会视图-->
    <div class="oppv" style="background-color: #E9EEF3;">
      <el-row>
        <el-col :span="20" :offset="2" style="color: #333333">
          <!--机会视图表单-->
          <el-row class="m-b-20 p-10-20 b-g-f border-style">
            <el-row>
              <div class="dialog__header">
                <span class="dialog__title">销售机会</span>
              </div>
            </el-row>
            <el-form ref="opp" :model="opportunity" label-width="100px" :rules="rules">
              <el-divider><span class="font-14-bold">机会</span></el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="机会主题:" prop="oppTheme">
                    <el-input v-model="opportunity.oppTheme" style="width: 79%" placeholder="机会主题"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="更新日期:">
                    <el-input v-model="opportunity.oppUpdateDate" style="width: 79%" :disabled="true"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                    <el-input :disabled="true" v-model="opportunity.customerByCustomerId.customerName" style="width: 79%"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="状态:">
                    <el-radio-group v-model="opportunity.oppStatus">
                      <el-radio :label="1">跟踪</el-radio>
                      <el-radio :disabled="true" :label="2">成功</el-radio>
                      <el-radio :label="3">失败</el-radio>
                      <el-radio :label="4">搁置</el-radio>
                      <el-radio :label="5">失效</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider><span class="font-14-bold">基本情况</span></el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item  label="客户联系人:">
                    <el-select v-model="opportunity.oppContactName" placeholder="未选" style="width: 79%">
                      <el-option v-for="(item,index) in contactList" :key="index" :label="item.contactName" :value="item.contactName">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="类型:">
                    <el-select v-model="opportunity.oppClassify" placeholder="未选" style="width: 79%">
                      <el-option v-for="(item,index) in lxOptions" :key="index" :label="item.label" :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="发现时间:">
                    <el-date-picker v-model="opportunity.oppFindDate" type="date" placeholder="选择日期" style="width: 79%"></el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="来源:">
                    <el-select v-model="opportunity.oppSource" placeholder="未选"  style="width: 79%">
                      <el-option v-for="(item, index) in lyOptions" :key="index" :value="item.value" :label="item.label">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="负责人:" prop="employeeByEmpId.empName">
                    <el-input :disabled="true" v-model="opportunity.employeeByEmpId.empName" style="width: 79%">
                      <el-button @click="openEmpDialog" slot="append" icon="el-icon-search"></el-button>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="提供人:">
                    <el-input v-model="opportunity.oppOffer" style="width: 79%"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-form-item label="客户需求:">
                    <el-input v-model="opportunity.oppNeed" style="width: 91%" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider><span class="font-14-bold">预期</span></el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="预计签单日期:">
                    <el-date-picker v-model="opportunity.oppSignDate" style="width: 79%" type="date" placeholder="选择日期"></el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="可能性:">
                    <el-select v-model="opportunity.oppPossibility" placeholder="未选" style="width: 79%">
                      <el-option v-for="(item,index) in knxOptions" :key="index" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="预期金额:" prop="oppExpectSum">
                    <el-input v-model.number="opportunity.oppExpectSum" style="width: 79%" placeholder=""></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider><span class="font-14-bold">当前状态</span></el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="阶段:" prop="oppStage">
                    <el-select v-model="opportunity.oppStage" placeholder="未选" style="width: 79%">
                      <el-option v-for="(item,index) in jdOptions" :key="index" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="优先:">
                    <el-select v-model="opportunity.oppPriority" placeholder="未选" style="width: 79%">
                      <el-option v-for="(item,index) in yxOptions" :key="index" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-form-item label="阶段备注:">
                    <el-input v-model="opportunity.oppPriRemark" style="width: 91%"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-form-item label="跟踪日志:">
                    <div v-if="traceList.length !== 0" class="gz-style">
                      <div :key="index" v-for="(trace,index) in traceList">
                        <span class="margin-r-3">日期：{{trace.traceDate}}</span>
                        <span class="margin-r-3">阶段：{{trace.traceStage}}（{{trace.tracePrincipal}}）</span>
                        <span class="margin-r-3">预计：{{trace.traceSignDate}}（￥{{trace.traceExpectSum}}）</span>
                        <span class="margin-r-3">备注：{{trace.tracePriRemark}}</span>
                      </div>
                    </div>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12" :offset="7">
                  <el-form-item>
                    <span v-if="this.opportunity.oppStatus !== 2">
                      <el-button type="danger" @click="handleDelete">删除</el-button>
                      <el-button @click="addOpportunity" type="primary">保存</el-button>
                    </span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <!--内层dialog员工-->
            <el-dialog width="30%" title="人员选择" :visible.sync="innerDialogEmp" append-to-body @close="closeInnerDialogEmp">
              <div>
                <el-collapse v-model="activeName">
                  <el-collapse-item v-for ="(dept,index) in deptList" :title="dept.deptName" :key="index" :name="dept.deptId">
                    <ul class="emp-ul">
                      <li @click="choiceEmp(emp)" v-for="(emp,index) in dept.employeeByDeptId">
                        <span v-if="index !== dept.employeeByDeptId.length-1" class="line-style"></span>
                        <span v-if="index === dept.employeeByDeptId.length-1" class="line-style-end"></span>
                        <span class="">{{emp.empName}}</span>
                      </li>
                    </ul>
                  </el-collapse-item>
                </el-collapse>
              </div>
            </el-dialog>
          </el-row>
          <el-row>
            <el-col :span="24">
              <p class="f-s-12">机会跟踪：<b>只显示该销售机/会显示该客户全部</b><font color="#808080">任务、行动</font></p>
            </el-col>
          </el-row>
          <!--机会跟踪-->
          <el-row>
            <el-col class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                <el-icon class="el-icon-s-grid"></el-icon>
                <span>待办任务</span>
                <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span @click="dialogTask = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                </el-tooltip>
              </div>
              <div class="p-10-20">
                <el-row :key="index" v-for="(task,index) in taskList" style="padding-bottom: 5px">
                  <el-icon class="el-icon-star-on"/>
                  <span @click="openTaskView(task)" class="cursor margin-r-5">{{task.taskDescribe}}</span>
                  <span class="margin-r-5">{{task.taskFinishDate | formatDateJudge}}</span>
                  <span class="margin-r-5">{{task.taskTime}}</span>
                  <span v-if="task.taskPriority == 1" class="margin-r-5">高</span>
                  <span v-if="task.taskPriority == 2" class="margin-r-5">低</span>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                <el-icon class="el-icon-goods"></el-icon>
                <span>行动历史记录</span>
                <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span @click="dialogAct = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                </el-tooltip>
              </div>
              <div class="p-10-20">
                <el-table :data="actionList" tooltip-effect="dark"
                          style="width: 100%;border-top: 1px solid #EBEEF5" :show-header="false">
                  <el-table-column prop="taskId" label="ID" wsortable sortable></el-table-column>
                  <el-table-column label="类型" >
                    <template slot-scope="scope">
                      <span style="color: black" v-if="scope.row.taskIs === 1">待办任务</span>
                      <span style="color: black" v-if="scope.row.taskIs === 2"><span class="margin-r-5">记录</span>{{actOptions[scope.row.taskClassify-1].label}}</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="taskDescribe" label="行动描述" >
                    <template slot-scope="scope">
                      <span class="cursor" v-if="scope.row.taskIs === 1" @click="openTask(scope.row)">{{scope.row.taskDescribe}}</span>
                      <span class="cursor" v-if="scope.row.taskIs === 2" @click="openAct(scope.row)">{{scope.row.taskDescribe}}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="是否执行" width="100">
                    <template slot-scope="scope">
                      <el-tooltip class="item" effect="dark" content="未结束" placement="bottom">
                        <span v-if="scope.row.taskStatus === 1" style="color: #215ca0">
                          <i class="el-icon-s-promotion"></i>
                        </span>
                      </el-tooltip>
                      <el-tooltip class="item" effect="dark" content="已结束" placement="bottom">
                        <span v-if="scope.row.taskStatus === 2" style="color: #215ca0">
                          <i class="el-icon-success"></i>
                        </span>
                      </el-tooltip>
                    </template>
                  </el-table-column>
                  <el-table-column label="执行人与客户" width="200">
                    <template slot-scope="scope">
                      <div>{{scope.row.taskExecutor}}<i class="el-icon-right"/>
                        {{scope.row.customerByCustomerId.customerName}}
                        <el-tooltip class="item" effect="dark" content="打开详细页面" placement="bottom">
                          <router-link :to="{path:'/customerview',query: {customerId: scope.row.customerByCustomerId.customerId}}">
                            <i style="color: #333333" class="el-icon-s-cooperation"></i>
                          </router-link>
                        </el-tooltip>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="taskFinishDate" label="时间" >
                    <template slot-scope="scope">
                      <span>{{scope.row.taskFinishDate | formatDateJudge}}</span>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-col>
          </el-row>
          <!--出差-->
          <el-row >
            <el-col class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                <el-icon class="el-icon-bicycle"></el-icon>
                <span>出差</span>
                <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span v-if="this.opportunity.oppStatus" @click="dialogBus = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                </el-tooltip>
              </div>
              <div class="p-10-20">
                <el-table ref="multipleTable" :data="businessList" tooltip-effect="dark"
                            style="width: 100%;border-top: 1px solid #EBEEF5" :show-header="false">
                  <el-table-column prop="businessId" label="ID" wsortable sortable></el-table-column>
                  <el-table-column label="主题" >
                      <template slot-scope="scope">
                        <router-link :to="{path:'/businessview',query: {businessId: scope.row.businessId}}">
                          <div style="color: #333333">
                            <i class="el-icon-caret-right"></i>
                            <span>{{scope.row.businessTheme}}</span>
                          </div>
                        </router-link>
                      </template>
                    </el-table-column>
                  <el-table-column prop="businessDestination" label="目的地" ></el-table-column>
                  <el-table-column prop="businessStartDate" label="开始时间" sortable>
                    <template slot-scope="scope">
                      <span>{{scope.row.businessStartDate | formatDateJudge}}</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="businessEndDate" label="结束时间" sortable>
                    <template slot-scope="scope">
                      <span>{{scope.row.businessEndDate | formatDateJudge}}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="状态" >
                      <template slot-scope="scope">
                        <span v-if="scope.row.businessClassify === 1">{{busOptions[0].label}}</span>
                        <span v-if="scope.row.businessClassify === 2">{{busOptions[1].label}}</span>
                        <span v-if="scope.row.businessClassify === 3">{{busOptions[2].label}}</span>
                        <span v-if="scope.row.businessClassify === 4">{{busOptions[3].label}}</span>
                      </template>
                    </el-table-column>
                  </el-table>
              </div>
            </el-col>
          </el-row>
          <!--需求、报价-->
          <el-row type="flex">
            <el-col :span="11" class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                  <el-icon class="el-icon-chat-line-square"></el-icon>
                  <span>详细需求</span>
                  <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span @click="dialogDem = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                  </el-tooltip>
                </div>
                <div class="p-10-20">
                  <el-row :key="index" v-for="(demand,index) in demandList" style="padding-bottom: 5px">
                    <el-icon class="el-icon-star-on"/>
                    <span @click="openDem(demand)" class="cursor margin-r-5">{{demand.demandTheme}}</span>
                    <span class="margin-r-5" v-if="demand.demandSign !== null">{{demOptions[demand.demandSign-1].label}}</span>
                    <span class="margin-r-5">{{demand.demandDate | formatDateJudge}}</span>
                  </el-row>
                </div>
            </el-col>
            <el-col :offset="1" :span="12" class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                <el-icon class="el-icon-document"></el-icon>
                <span>报价单</span>
                <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span @click="dialogQuo = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                </el-tooltip>
              </div>
              <div class="p-10-20">
                <div :key="index" v-for="(quo,index) in quotationList" style="padding-bottom: 5px">
                  <div>
                    <el-icon class="el-icon-star-on"/>
                    <span class="margin-r-5 cursor" @click="openQuo(quo)">{{quo.quotationTheme}}</span>
                    <span class="margin-r-5">{{quo.quotationDate | formatDateJudge}}</span>
                    <span class="margin-r-5"><span style="color: #999">报价：</span>￥{{quo.quotationPrice}}</span>
                  </div>
                  <el-row style="font-size: 14px;padding: 10px">
                    <el-col @click.native="openPro(quo.quotationId)" :offset="1" :span="6" class="cursor"><el-icon class="el-icon-edit-outline"/>编辑明细</el-col>
                    <el-col @click.native="openQuo(quo)" :span="6" class="cursor"><el-icon class="el-icon-view"/>查看明显</el-col>
                    <el-col v-if="quo.quotationStatus !== 3" @click.native="repealOrder(quo)" :span="11" class="cursor"><el-icon class="el-icon-finished"/>转成订单</el-col>
                  </el-row>
                </div>
              </div>
            </el-col>
          </el-row>
          <!-- 方案、竞争-->
          <el-row type="flex">
            <el-col :span="11" class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                <el-icon class="el-icon-success"></el-icon>
                <span>解决方案</span>
                <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span @click="dialogSol = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                </el-tooltip>
              </div>
              <div class="p-10-20">
                <div :key="index" v-for="(sol,index) in solutionList" style="padding-bottom: 5px">
                  <el-icon class="el-icon-star-on"/>
                  <span class="margin-r-5 cursor" @click="openSol(sol)">{{sol.solutionTheme}}</span>
                  <span class="margin-r-5">{{sol.solutionDate | formatDateJudge}}</span>
                </div>
              </div>
            </el-col>
            <el-col :offset="1" :span="12" class="m-b-20 b-g-f border-style">
              <div class="p-10-20 f-w">
                <el-icon class="el-icon-info"></el-icon>
                <span>竞争对手</span>
                <el-tooltip class="item" effect="dark" content="新建" placement="bottom">
                <span @click="dialogCom = true">
                  <el-icon class="el-icon-plus cursor" ></el-icon>
                </span>
                </el-tooltip>
              </div>
              <div class="p-10-20">
                <div :key="index" v-for="(com,index) in competitorList" style="padding-bottom: 5px">
                  <el-icon class="el-icon-star-on"/>
                  <span class="margin-r-5 cursor" @click="openCom(com)">{{com.competitorName}}</span>
                  <span class="margin-r-5"><span style="color: #999">报价：</span>￥{{com.competitorPrice}}</span>
                  <span class="margin-r-5" v-if="com.competitorCapacity !== null">{{comOptions[com.competitorCapacity].label}}</span>
                </div>
              </div>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row>
        <!--待办任务dialog-->
        <el-dialog title="待办任务" :visible.sync="dialogTask" width="60%" style="color: #333333"
              @open="openDialogTask" @close="closeDialogTask">
          <el-form ref="task" :model="task" label-width="100px" :rules="taskRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col>
                <el-form-item label="行动描述:" prop="taskDescribe">
                  <el-input v-model="task.taskDescribe" type="textarea" :autosize="{ minRows: 2, maxRows: 4}"  style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="执行人:" prop="employeeByExeEmpId.empName">
                  <el-input :disabled="true" v-model="task.employeeByExeEmpId.empName" style="width: 91%">
                    <el-button @click="openEmpDialog" slot="append" icon="el-icon-search" ></el-button>
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="完成期限:">
                  <el-date-picker v-model="task.taskFinishDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width: 79%"></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="时间:">
                  <el-time-picker v-model="task.taskTime" value-format="hh:mm:ss" style="width:79%" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}"
                    placeholder="任意时间点">
                  </el-time-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8" style="line-height: 40px">
                <el-form-item label="优先:">
                  <el-radio-group v-model="task.taskPriority">
                    <el-radio :label="1">高</el-radio>
                    <el-radio :label="2">低</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="task.customerByCustomerId.customerName" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" style="line-height: 40px">
                <el-form-item label="联系人:">
                  <el-select v-model="task.taskContactName" placeholder="未选" style="width: 79%">
                    <el-option v-for="(item,index) in contactList" :key="index" :label="item.contactName" :value="item.contactName">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="状态:">
                  <el-radio-group v-model="task.taskStatus">
                    <el-radio :label="1">未结束</el-radio>
                    <el-radio :label="2">已结束</el-radio>
                    <el-radio :label="3">取消</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="创建人:" >
                  <el-input v-model="task.employeeByEmpId.empName" :disabled="true" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="创建时间:">
                  <el-input v-model="task.taskCreateDate" :disabled="true" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="6">
                <el-form-item>
                  <el-button v-if="this.task.taskId !== 0 " @click="handleDeleteTask" type="danger">删除</el-button>
                  <el-button @click="saveTask" type="primary">保存</el-button>
                  <el-button @click="dialogTask = false">取消</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!--行动历史记录dialog-->
        <el-dialog title="行动历史记录" :visible.sync="dialogAct" width="60%" style="color: #333333"
                   @open="openDialogAct" @close="closeDialogAct">
          <el-form ref="act" :model="action" label-width="100px" :rules="actRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col>
                <el-form-item label="行动描述:" prop="taskDescribe">
                  <el-input v-model="action.taskDescribe" type="textarea" :autosize="{ minRows: 2, maxRows: 4}"  style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="action.customerByCustomerId.customerName" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" style="line-height: 40px">
                <el-form-item label="联系人:">
                  <el-select v-model="action.taskContactName" placeholder="未选" style="width: 79%">
                    <el-option v-for="(item,index) in contactList" :key="index" :label="item.contactName" :value="item.contactName">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12" style="line-height: 40px">
                <el-form-item label="维修单:">
                  <el-input :disabled="true" placeholder="未选" style="width: 79%">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="类型:" prop="taskClassify">
                  <el-select v-model="action.taskClassify" placeholder="未选" style="width: 270px">
                    <el-option v-for="item in actOptions" :key="item.label" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="日期:">
                  <el-date-picker v-model="action.taskFinishDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width:79%"></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="执行人:" prop="employeeByExeEmpId.empName">
                  <el-input :disabled="true" v-model="action.employeeByExeEmpId.empName" style="width: 91%">
                    <el-button @click="openEmpDialog" slot="append" icon="el-icon-search" ></el-button>
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="7">
                <el-form-item>
                  <el-button v-if="this.action.taskId !== 0 " @click="handleDeleteAct" type="danger">删除</el-button>
                  <el-button @click="saveAction" type="primary">保存</el-button>
                  <el-button @click="dialogAct = false">取消</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!--出差-->
        <el-dialog title="出差" :visible.sync="dialogBus" width="60%" @open="openDialogBus" @close="closeDialogBus" style="color: #333333"  >
          <el-form ref="bus" :model="business" label-width="100px" :rules="busRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col>
                <el-form-item label="主题:" prop="businessTheme">
                  <el-input v-model="business.businessTheme" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间:" >
                  <el-date-picker v-model="business.businessStartDate" type="date" placeholder="任意时间点" style="width: 79%">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间:">
                  <el-date-picker v-model="business.businessEndDate" type="date" placeholder="任意时间点" style="width: 79%">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col style="line-height: 40px">
                <el-form-item label="目的地:">
                  <el-input v-model="business.businessDestination" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="交通工具:">
                  <el-select v-model="business.businessVehicle" placeholder="未选" style="width: 91%">
                    <el-option v-for="item in jtOptions" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="business.customerByCustomerId.customerName" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="借款:" prop="businessMoney">
                  <el-input v-model.number="business.businessMoney" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="申请人:" prop="employeeByEmpId.empName">
                  <el-input :disabled="true" v-model="business.employeeByEmpId.empName" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="状态:">
                  <el-select v-model="business.businessClassify" placeholder="未选" style="width: 79%">
                    <el-option v-for="item in busOptions" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="备注:">
                  <el-input v-model="business.businessRemarks"  style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="审批状态:" style="width: 91%">
                  <div v-if="this.business.businessId !== 0">
                    <div v-if="this.business.businessAppStatus === 0">
                      <span>待申请</span>
                      <el-tooltip class="item" effect="dark" content="待申请" placement="bottom">
                        <i class="el-icon-more font-18"></i>
                      </el-tooltip>
                    </div>
                    <div v-if="this.business.businessAppStatus === 1">
                      <span>待审批</span>
                      <el-tooltip class="item" effect="dark" content="待审批" placement="bottom">
                        <i class="el-icon-s-opportunity font-18"></i>
                      </el-tooltip>
                    </div>
                    <div v-if="this.business.businessAppStatus === 2">
                      <span>同意</span>
                      <el-tooltip class="item" effect="dark" content="同意" placement="bottom">
                        <i class="el-icon-circle-check font-18"></i>
                      </el-tooltip>
                      <span>审批人：{{business.employeeByEmpId.empName}}</span>
                    </div>
                    <div v-if="this.business.businessAppStatus === 3">
                      <span>否决</span>
                      <el-tooltip class="item" effect="dark" content="否决" placement="bottom">
                        <i class="el-icon-circle-close font-18"></i>
                        <span>审批人：{{business.employeeByEmpId.empName}}</span>
                      </el-tooltip>
                    </div>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="审批记录:" style="width: 91%">
                  <el-row></el-row>
                  <el-row :key="index" v-for="(app,index) in approvalRecordList">
                    <div class="border-bo" >
                      <div class="font-13-bold">
                        <span>申请：</span>
                        <span class="margin-r-3">{{app.employeeByApplicantEmpId.empName}}<i class="el-icon-right"/> boss用户</span>
                        <span>{{app.approvalRecordDate}}</span>
                      </div>
                      <div class="font-13" v-if="app.employeeByApprovalEmpId !== null">
                        <span class="margin-r-3"><i class="el-icon-minus"/>{{app.employeeByApprovalEmpId.empName}}</span>
                        <span class="margin-r-3">{{app.approvalRecordTime | formatDate}}</span>
                        <span class="margin-r-3">{{app.approvalRecordOper}}</span>
                        <span>备注：{{app.approvalRecordNote}}</span>
                      </div>
                    </div>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="7">
                <el-form-item>
                  <el-button @click="addBusiness" type="primary">保存</el-button>
                  <el-button @click="dialogBus = false">取消</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!--详细需求dialog-->
        <el-dialog title="详细需求" :visible.sync="dialogDem" width="60%" style="color: #333333"
                   @open="openDialogDem" @close="closeDialogDem">
          <el-form ref="dem" :model="demand" label-width="100px" :rules="demRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col>
                <el-form-item label="需求主题:" prop="demandTheme" >
                  <el-input  v-model="demand.demandTheme" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="需求提供人:">
                  <el-input v-model="demand.demandOffer" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="demand.customerByCustomerId.customerName" style="width: 91%" placeholder=""></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="对应机会:" prop="opportunityByOppId.oppTheme">
                  <el-input :disabled="true" v-model="demand.opportunityByOppId.oppTheme" placeholder="未选" style="width: 91%"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="记录时间:">
                  <el-date-picker v-model="demand.demandDate"  type="date" placeholder="选择日期" style="width: 79%"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="重要程度:" prop="demandSign">
                  <el-select v-model="demand.demandSign" placeholder="未选" style="width: 79%">
                    <el-option v-for="item in demOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户需求:">
                  <el-input v-model="demand.demandContent" style="width: 91%" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="5">
                <el-form-item>
                  <el-button v-if="this.demand.demandId !== 0 " @click="handleDeleteDem" type="danger">删除</el-button>
                  <el-button @click="addDemand" type="primary">保存</el-button>
                  <el-button @click="dialogDem = false">取消</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!--报价单-->
        <el-dialog title="报价/预下单" :visible.sync="dialogQuo" @open="openDialogQuo" @close="closeDialogQuo" width="60%" style="color: #333333"  >
          <el-form :model="quotation" ref="quo" label-width="100px" :rules="quoRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题:" prop="quotationTheme">
                  <el-input v-model="quotation.quotationTheme" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="转成订单:">
                  <el-radio-group v-model="quotation.quotationStatus">
                    <el-radio :label="1">可见</el-radio>
                    <el-radio :label="2">不可见</el-radio>
                    <el-radio :disabled="true" :label="3">转成订单</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="quotation.customerByCustomerId.customerName" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="报价单号:">
                  <el-input :disabled="true" v-model="quotation.quotationNo" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="分类:">
                  <el-select v-model="quotation.quotationClassify" placeholder="未选" style="width: 79%">
                    <el-option v-for="(item,index) in quoOptions" :key="index" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="日期:">
                  <el-date-picker v-model="quotation.quotationDate" type="date" placeholder="选择日期" style="width: 79%"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="报价:" prop="quotationPrice">
                  <el-input v-model.number="quotation.quotationPrice" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="销售机会:" prop="opportunityByOppId.oppTheme">
                  <el-input :disabled="true" v-model="quotation.opportunityByOppId.oppTheme" placeholder="未选" style="width: 91%">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="明细:" style="width: 92%">
                  <el-row v-if="this.quotation.quotationId !== 0">
                    <el-row>
                      <el-col :span="4" :offset="16">
                        <span class="cursor" @click="openPro(quotation.quotationId)"><i class="el-icon-edit"></i>编辑明细</span>
                      </el-col>
                      <el-col :span="4">
                        <span  @click="printPdf(quotation.quotationId)" class="cursor"><i class="el-icon-printer"></i>打印单据</span>
                      </el-col>
                    </el-row>
                    <div class="detail">
                      <el-table :data="detailList" style="width: 100%" border show-summary>
                        <el-table-column prop="productByProductId.productName" label="产品名" >
                        </el-table-column>
                        <el-table-column prop="productByProductId.productModel" label="型号" >
                        </el-table-column>
                        <el-table-column prop="productDetailCount" label="数量" >
                        </el-table-column>
                        <el-table-column prop="productByProductId.productPrice" label="单价" >
                        </el-table-column>
                        <el-table-column prop="productDetailMoney" label="金额" >
                          <template slot-scope="scope">
                            {{ (scope.row.productDetailMoney = scope.row.productByProductId.productPrice *scope.row.productDetailCount)}}
                          </template>
                        </el-table-column>
                        <el-table-column prop="productDetailRemarks" label="备注" >
                        </el-table-column>
                      </el-table>
                    </div>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item  label="接受人:" prop="quotationContactName">
                  <el-select v-model="quotation.quotationContactName"  placeholder="未选" style="width: 91%">
                    <el-option v-for="(item,index) in contactList" :key="index" :label="item.contactName" :value="item.contactName">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="报价人:" prop="employeeByEmpId.empName">
                  <el-input :disabled="true" v-model="quotation.employeeByEmpId.empName" style="width: 91%">
                    <el-button @click="openEmpDialog" slot="append" icon="el-icon-search"></el-button>
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="交付说明:">
                  <el-input v-model="quotation.quotationDelivery" style="width: 91%" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="付款方式:">
                  <el-input v-model="quotation.quotationPayment" style="width: 91%" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="包装运输说明:">
                  <el-input v-model="quotation.quotationPackage" style="width: 91%" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="备注:">
                  <el-input v-model="quotation.quotationRemarks" style="width: 91%" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="审批状态:" style="width:91%">
                  <div v-if="this.quotation.quotationId !== 0">
                    <div v-if="this.quotation.quotationAppStatus === 0">
                      <span>待申请</span>
                      <el-tooltip class="item" effect="dark" content="待申请" placement="bottom">
                        <i class="el-icon-more font-18"></i>
                      </el-tooltip>
                    </div>
                    <div v-if="this.quotation.quotationAppStatus === 1">
                      <span>待审批</span>
                      <el-tooltip class="item" effect="dark" content="待审批" placement="bottom">
                        <i class="el-icon-s-opportunity font-18"></i>
                      </el-tooltip>
                    </div>
                    <div v-if="this.quotation.quotationAppStatus === 2">
                      <span>同意</span>
                      <el-tooltip class="item" effect="dark" content="同意" placement="bottom">
                        <i class="el-icon-circle-check font-18"></i>
                      </el-tooltip>
                      <span>审批人：{{quotation.employeeByAppEmpId.empName}}</span>
                    </div>
                    <div v-if="this.quotation.quotationAppStatus === 3">
                      <span>否决</span>
                      <el-tooltip class="item" effect="dark" content="否决" placement="bottom">
                        <i class="el-icon-circle-close font-18"></i>
                        <span>审批人：{{quotation.employeeByAppEmpId.empName}}</span>
                      </el-tooltip>
                    </div>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="审批记录:" style="width:91%">
                  <el-row></el-row>
                  <el-row :key="index" v-for="(app,index) in approvalRecordList">
                    <div class="border-bo" >
                      <div class="font-13-bold">
                        <span>申请：</span>
                        <span class="margin-r-3">{{app.employeeByApplicantEmpId.empName}}<i class="el-icon-right"/> boss用户</span>
                        <span>{{app.approvalRecordDate}}</span>
                      </div>
                      <div class="font-13" v-if="app.employeeByApprovalEmpId !== null">
                        <span class="margin-r-3"><i class="el-icon-minus"/>{{app.employeeByApprovalEmpId.empName}}</span>
                        <span class="margin-r-3">{{app.approvalRecordTime | formatDate}}</span>
                        <span class="margin-r-3">{{app.approvalRecordOper}}</span>
                        <span>备注：{{app.approvalRecordNote}}</span>
                      </div>
                    </div>
                  </el-row>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="7">
                <el-form-item>
                  <span v-if="this.quotation.quotationAppStatus !== 2">
                    <el-button v-if="this.quotation.quotationId !== 0 " @click="handleDeleteQuo" type="danger">删除</el-button>
                    <el-button @click="addQuotation" type="primary">保存</el-button>
                    <el-button @click="dialogQuo = false">取消</el-button>
                  </span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!--解决方案-->
        <el-dialog title="解决方案" :visible.sync="dialogSol" @open="openDialogSol" @close="closeDialogSol" width="60%" style="color: #333333"  >
          <el-form ref="sol" :model="solution" label-width="100px" :rules="solRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="solution.customerByCustomerId.customerName" placeholder="" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="方案主题:" prop="solutionTheme">
                  <el-input v-model="solution.solutionTheme" placeholder="" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="对应机会:" prop="opportunityByOppId.oppTheme">
                  <el-input :disabled="true" v-model="solution.opportunityByOppId.oppTheme" placeholder="未选" style="width: 79%">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="发现时间:">
                  <el-date-picker v-model="solution.solutionDate"  type="date" placeholder="选择日期" style="width: 79%"></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="方案内容:">
                  <el-input v-model="solution.solutionContent" type="textarea" :autosize="{ minRows: 2, maxRows: 4}"  style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户反馈:" style="width: 810px">
                  <el-input v-model="solution.solutionFeedback" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="7">
                <el-form-item>
                  <el-button v-if="this.solution.solutionId !== 0 " @click="handleDeleteSol" type="danger">删除</el-button>
                  <el-button @click="addSolution" type="primary">保存</el-button>
                  <el-button @click="dialogSol = false">取消</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
        <!--竞争对手-->
        <el-dialog title="竞争对手" :visible.sync="dialogCom" @open="openDialogCom" @close="closeDialogCom" width="60%" style="color: #333333"  >
          <el-form ref="com" :model="competitor" label-width="100px" :rules="comRules">
            <el-divider><span class="font-14-bold"></span></el-divider>
            <el-row>
              <el-col>
                <el-form-item label="公司名称:" prop="competitorName">
                  <el-input v-model="competitor.competitorName" placeholder="" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="客户:" prop="customerByCustomerId.customerName">
                  <el-input :disabled="true" v-model="competitor.customerByCustomerId.customerName" placeholder="" style="width: 91%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="对应机会:" prop="opportunityByOppId.oppTheme">
                  <el-select :disabled="true" v-model="competitor.opportunityByOppId.oppTheme" placeholder="未选" style="width: 91%">
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="价格:" prop="competitorPrice">
                  <el-input v-model.number="competitor.competitorPrice" placeholder="" style="width: 79%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="竞争能力:" prop="competitorCapacity">
                  <el-select v-model="competitor.competitorCapacity" placeholder="未选" style="width: 79%">
                    <el-option v-for="item in comOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="竞争/方案:">
                  <el-input v-model="competitor.competitorProduct" type="textarea" style="width: 91%" :autosize="{ minRows: 2, maxRows: 4}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="优势:">
                  <el-input v-model="competitor.competitorStrengths" type="textarea" style="width: 91%" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="劣势:">
                  <el-input v-model="competitor.competitorWeaknesses" type="textarea" style="width: 91%" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="应对策略:">
                  <el-input v-model="competitor.competitorStrategy" type="textarea" style="width: 91%" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注:">
                  <el-input v-model="competitor.competitorRemarks" type="textarea" style="width: 91%" :autosize="{ minRows: 2, maxRows: 4}" ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12" :offset="7">
                <el-form-item>
                  <el-button v-if="this.competitor.competitorId !== 0 " @click="handleDeleteCom" type="danger">删除</el-button>
                  <el-button @click="addCompetitor" type="primary">保存</el-button>
                  <el-button @click="dialogCom = false">取消</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-dialog>
      </el-row>
    </div>
</template>

<script>
  import {formatTimeToStr} from "../assets/format";

  export default {
  data () {
    return {
      dialogTask: false,
      dialogAct: false,
      dialogBus: false,
      dialogDem: false,
      dialogQuo: false,
      dialogSol: false,
      dialogCom: false,
      opportunity: {
        oppId: 0,
        oppTheme: '',
        oppUpdateDate: '',
        oppStatus: '',
        oppClassify: '',
        oppFindDate: '',
        oppSource: '',
        oppOffer: '',
        oppNeed: '',
        oppSignDate: '',
        oppPossibility: '',
        oppExpectSum: '',
        oppStage: '',
        oppPriRemark: '',
        oppPriority: '',
        oppContactName: '',
        customerByCustomerId: '',
        employeeByEmpId: ''
      },//表单机会
      innerDialogEmp: false,// 内层dialog员工
      activeName: [],
      deptList:[],
      contactList: [], // 员工联系人集合
      traceList: [],// 机会跟踪集合
      trace: {
        traceId:0,
        traceDate:'',
        traceStage:'',
        tracePrincipal:'',
        traceSignDate:'',
        traceExpectSum:'',
        tracePriRemark:'',
        opportunityByOppId:''
      },
      rules: {
        oppTheme: [{
          required: true,
          message: '必须填',
          trigger: 'blur'
        }, {
          min: 2,
          max: 20,
          message: '长度在 2 到 20 个字符',
          trigger: 'blur'
        }],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        'employeeByEmpId.empName': [
          { required: true, message: '请选择负责人', trigger: 'blur' }
        ],
        oppStage: [
          { required: true, message: '必须填', trigger: 'blur' }
        ],
        oppExpectSum: [
          { required: true, message: '必须填'},
          { type: 'number', message: '必须为数字'}
        ]
      }, // 表单验证
      taskList: [],//待办任务集合
      task: {
        taskId:0,
        taskDescribe:'',
        taskContactName:'',
        taskFinishDate:'',
        taskTime:null,
        taskPriority:'',
        taskStatus:'',
        taskCreateDate:'',
        taskIs:'',
        opportunityByOppId:null,
        customerByCustomerId:{},
        employeeByEmpId:'',
        employeeByExeEmpId:{},
      },
      taskRules: {
        taskDescribe: [
          {required: true, message: '必须填', trigger: 'blur'}
        ],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        'employeeByExeEmpId.empName': [
          { required: true, message: '请选择负责人', trigger: 'blur' }
        ]
      },
      actionList: [],
      action:{
        taskId:0,
        taskDescribe:'',
        taskContactName:'',
        taskFinishDate:'',
        taskClassify:'',
        taskIs:'',
        opportunityByOppId:null,
        customerByCustomerId:{},
        employeeByEmpId:'',
        employeeByExeEmpId:{},
      },
      actRules: {
        taskDescribe: [
          {required: true, message: '必须填', trigger: 'blur'}
        ],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        'employeeByExeEmpId.empName': [
          { required: true, message: '请选择负责人', trigger: 'blur' }
        ],
        taskClassify: [
          { required: true, message: '必须填', trigger: 'change' }
        ]
      },
      businessList: [], // 出差集合
      business: {
        businessId: 0,
        businessTheme: '',
        businessStartDate: '',
        businessEndDate: '',
        businessDestination: '',
        businessVehicle: '',
        businessMoney: '',
        businessClassify: '',
        businessRemarks: '',
        businessPeer: '',
        businessAppStatus: 0,
        customerByCustomerId:'',
        employeeByEmpId:'',
        employeeByAppEmpId:null,
        opportunityByOppId:null
      },
      busRules: {
        businessTheme: [{
          required: true,
          message: '必须填',
          trigger: 'blur'
        }],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        'employeeByEmpId.empName': [
          { required: true, message: '请选择负责人', trigger: 'blur' }
        ],
        businessMoney: [
          { required: true, message: '必须填'},
          { type: 'number', message: '必须为数字'}
        ]
      },
      demandList: [], // 需求集合
      demand: {
        demandId: 0,
        demandTheme: '',
        demandOffer: '',
        demandDate: '',
        demandSign: '',
        demandContent: '',
        opportunityByOppId: '',
        customerByCustomerId:{}
      },
      demRules: {
        demandTheme: [{
          required: true,
          message: '必须填',
          trigger: 'blur'
        }],
        'opportunityByOppId.oppTheme': [
          { required: true, message: '请选择机会', trigger: 'change' }
        ],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        demandSign: [
          { required: true, message: '必选', trigger: 'change' }
        ]
      },
      quotationList: [], // 报价集合分页
      quotation: {
        quotationId: 0,
        quotationTheme: '',
        quotationNo: '',
        quotationStatus: '',
        quotationClassify: '',
        quotationDate: '',
        quotationPrice: '',
        quotationDelivery: '',
        quotationPayment: '',
        quotationPackage: '',
        quotationRemarks: '',
        quotationContactName: '',
        quotationAppStatus: 0,
        opportunityByOppId: '',
        customerByCustomerId:'',
        employeeByEmpId:'',
        employeeByAppEmpId:null
      },
      quoRules: {
        quotationTheme: [{
          required: true,
          message: '必须填',
          trigger: 'blur'
        }],
        opportunityByOppId : [
          { required: true, message: '请选择机会', trigger: 'change' }
        ],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        'employeeByEmpId.empName': [
          { required: true, message: '请选择负责人', trigger: 'blur' }
        ],
        quotationPrice: [
          { required: true, message: '必须填'},
          { type: 'number', message: '必须为数字'}
        ]
      },
      approvalRecordList:[],// 审批记录集合
      detailList: [], // 明细集合
      solutionList: [], // 解决方案集合
      solution: {
        solutionId: 0,
        solutionTheme: '',
        solutionDate: '',
        solutionFeedback: '',
        solutionContent: '',
        opportunityByOppId: '',
        customerByCustomerId:{}
      },
      solRules: {
        solutionTheme: [{
          required: true,
          message: '必须填',
          trigger: 'blur'
        }],
        'opportunityByOppId.oppTheme': [
          { required: true, message: '请选择机会', trigger: 'change' }
        ],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ]
      },
      competitorList: [],
      competitor: {
        competitorId: 0,
        competitorName: '',
        competitorPrice: '',
        competitorCapacity: '',
        competitorProduct: '',
        competitorStrengths: '',
        competitorWeaknesses: '',
        competitorStrategy: '',
        competitorRemarks: '',
        opportunityByOppId: '',
        customerByCustomerId: {}
      },
      comRules: {
        competitorName: [{
          required: true,
          message: '必须填',
          trigger: 'blur'
        }],
        'opportunityByOppId.oppTheme': [
          { required: true, message: '请选择机会', trigger: 'change' }
        ],
        'customerByCustomerId.customerName': [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        competitorPrice: [
          { required: true, message: '必须填'},
          { type: 'number', message: '必须为数字'}
        ],
        competitorCapacity: [
          { required: true, message: '必选', trigger: 'change' }
        ]
      },
      // 下拉列表
      yxOptions: [{
        value: 1,
        label: '一级'
      }, {
        value: 2,
        label: '二级'
      }, {
        value: 3,
        label: '三级'
      }],
      lxOptions: [{
        value: 1,
        label: '潜在销售机会'
      }, {
        value: 2,
        label: '显露销售机会'
      }],
      lyOptions: [{
        value: 1,
        label: '电话来访'
      }, {
        value: 2,
        label: '客户介绍'
      }, {
        value: 3,
        label: '媒体宣传'
      }, {
        value: 4,
        label: '老客户'
      }, {
        value: 5,
        label: '合作伙伴'
      }, {
        value: 6,
        label: '互联网'
      }, {
        value: 7,
        label: '其他'
      }],
      knxOptions: [{
        value: 1,
        label: '0%'
      }, {
        value: 2,
        label: '10%'
      }, {
        value: 3,
        label: '20%'
      }, {
        value: 4,
        label: '30%'
      }, {
        value: 5,
        label: '40%'
      }, {
        value: 6,
        label: '50%'
      }, {
        value: 7,
        label: '60%'
      }, {
        value: 8,
        label: '70%'
      }, {
        value: 9,
        label: '80%'
      }, {
        value: 10,
        label: '90%'
      }, {
        value: 11,
        label: '100%'
      }],
      jdOptions: [{
        value: 1,
        label: '初期沟通'
      }, {
        value: 2,
        label: '立体评估'
      }, {
        value: 3,
        label: '需求分析'
      }, {
        value: 4,
        label: '方案制定'
      }, {
        value: 5,
        label: '竞争'
      }, {
        value: 6,
        label: '商务谈判'
      }, {
        value: 7,
        label: '合同签约'
      }],
      ztOptions: [{
        value: 1,
        label: '跟踪'
      }, {
        value: 2,
        label: '成功'
      }, {
        value: 3,
        label: '失败'
      }, {
        value: 4,
        label: '搁置'
      }, {
        value: 5,
        label: '失效'
      }],
      actOptions: [{
        value: 1,
        label: '电话'
      }, {
        value: 2,
        label: '上门'
      }, {
        value: 3,
        label: '来访接待'
      }, {
        value: 4,
        label: '会议'
      },{
        value: 5,
        label: '培训'
      }, {
        value: 6,
        label: '商务餐旅'
      }, {
        value: 7,
        label: '外出活动'
      },{
        value: 8,
        label: '其他'
      }, {
        value: 9,
        label: '微信记录'
      }, {
        value: 10,
        label: 'QQ记录'
      }, {
        value: 11,
        label: '电话随记'
      }],
      busOptions: [{
        value: 1,
        label: '未出差'
      }, {
        value: 2,
        label: '出差中'
      }, {
        value: 3,
        label: '出差完成'
      }],
      jtOptions: [{
        value: 1,
        label: '高铁'
      }, {
        value: 2,
        label: '动车'
      }, {
        value: 3,
        label: '火车'
      }, {
        value: 4,
        label: '飞机'
      }, {
        value: 5,
        label: '汽车'
      }, {
        value: 6,
        label: '其他'
      }],
      demOptions: [{
        value: 1,
        label: '非常重要'
      }, {
        value: 2,
        label: '重要'
      }, {
        value: 3,
        label: '一般'
      }, {
        value: 4,
        label: '不重要'
      }],
      quoOptions: [{
        value: 1,
        label: '证券报价'
      }, {
        value: 2,
        label: '投标报价'
      }, {
        value: 3,
        label: '产品报价'
      }],
      comOptions: [{
        value: 1,
        label: '核心竞争'
      }, {
        value: 2,
        label: '有力竞争'
      }, {
        value: 3,
        label: '一般竞争'
      }, {
        value: 4,
        label: '忽略竞争'
      }]
    }
  },
  methods: {
    // 查询当前员工
    loginEmp(){
      this.$axios.get('http://localhost:8088/emp')
        .then(v => {
          this.emp = v.data
        })
        .catch(function (v) {})
    },
    // 查询机会
    initData () {
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/emp-opp-id', {
        params: {
          oppId : oppId
        }
      })
        .then(v => {
          this.opportunity = v.data
          this.choiceContact()
        })
        .catch(function (v) {})
    },
    // 查询跟踪日志
    findTrace(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/trace-list',{
        params:{
          oppId:oppId
        }
      })
        .then(v => {
          this.traceList = v.data
        })
        .catch(function (v) {})
    },
    // 修改销售机会
    addOpportunity () {
      // 状态
      this.opportunity.oppUpdateDate = this.addDate()
      this.saveTrace()
      this.$refs.opp.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-opportunity',this.opportunity)
            .then(v => {
              this.initData()
              this.findTrace()
              this.$message({
                message: '保存成功！',
                type: 'success'
              });
            })
            .catch(function (v) {})
        }
      })
    },
    // 新增跟踪日志
    saveTrace(){
      this.trace.traceDate = this.addDate()
      if (this.opportunity.oppStage !== null){
        this.trace.traceStage = this.jdOptions[this.opportunity.oppStage-1].label
      }
      if (this.opportunity.oppPossibility !== null){
        this.trace.tracePrincipal = this.knxOptions[this.opportunity.oppPossibility-1].label
      }
      this.trace.traceSignDate = this.opportunity.oppSignDate
      this.trace.traceExpectSum = this.opportunity.oppExpectSum
      this.trace.tracePriRemark = this.opportunity.oppPriRemark
      this.trace.opportunityByOppId = this.opportunity
      this.$axios.post('http://localhost:8088/save-trace',this.trace)
        .then(v => {
          this.trace = {
            traceId:0,
            traceDate:'',
            traceStage:'',
            tracePrincipal:'',
            traceSignDate:'',
            traceExpectSum:'',
            tracePriRemark:'',
            opportunityByOppId:''
          }
        })
        .catch(function (v) {})
    },
    // 查询联系人集合
    choiceContact(){
      this.$axios.get('http://localhost:8088/contact-list', {
        params: {
          customerId : this.opportunity.customerByCustomerId.customerId
        }
      })
        .then(v => {
          this.contactList = v.data
        })
        .catch(function (v) {})
    },
    //查询部门员工
    findDeptList () {
      this.$axios.get('http://localhost:8088/dept-emp-list')
        .then(v => {
          this.deptList = v.data
          for(let i = 1;i <= this.deptList.length;i++){
            this.activeName.push(i)
          }
        })
        .catch(function (v) {})
    },
    //打开员工dialog
    openEmpDialog(){
      this.innerDialogEmp = true
      this.findDeptList()
    },
    // 选择员工
    choiceEmp(val) {
      if (this.dialogTask === true){
        this.task.employeeByExeEmpId = val
      }else if (this.dialogAct === true){
        this.action.employeeByExeEmpId = val
      }else if (this.dialogQuo === true){
        this.quotation.employeeByEmpId = val
      }else {
        this.opportunity.employeeByEmpId = val
      }
      this.innerDialogEmp = false;
    },
    //关闭员工diglog事件
    closeInnerDialogEmp(){
      this.activeName = []
    },
    // 删除机会提示
    handleDelete () {
      this.$confirm('此操作将永久删除销售机会, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteOpp()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除机会axios
    deleteOpp(){
      let oppId = this.$route.query.oppId
      this.$axios.post('http://localhost:8088/delete-opportunity', this.qs.stringify({oppId: oppId}))
        .then(v => {
          this.$router.push('/opportunity');
        })
        .catch(function (v) {})
    },
    // 查询代办任务
    findTask(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/task-opp-list',{
        params:{
          oppId:oppId
        }
      })
      .then(v => {
        this.taskList = v.data
      })
      .catch(function (v) {})
    },
    // 进入待办任务视图
    openTaskView(val){
      this.$router.push({path:'/taskview',query: {taskId: val.taskId}});
    },
    // 待办任务数据回显
    openTask(val){
      this.dialogTask = true;
      this.task.taskId = val.taskId
      this.task.taskDescribe = val.taskDescribe
      this.task.employeeByExeEmpId = this.emp
      this.task.taskContactName = val.taskContactName
      this.task.taskFinishDate = val.taskFinishDate
      this.task.taskCreateDate = val.taskCreateDate
      this.task.taskTime = val.taskTime
      this.task.taskStatus = val.taskStatus
      this.task.taskPriority = val.taskPriority
      this.task.customerByCustomerId = val.customerByCustomerId
      this.task.employeeByEmpId = val.employeeByEmpId
      this.task.opportunityByOppId = this.opportunity
    },
    // 打开代办任务dialog事件
    openDialogTask () {
      if (this.task.taskId === 0){
        this.task.customerByCustomerId = this.opportunity.customerByCustomerId
        this.task.employeeByExeEmpId = this.emp
        this.task.opportunityByOppId = this.opportunity
        this.task.taskFinishDate = this.addDate()
        this.task.taskStatus = 1
        this.task.taskPriority = 1
      }
    },
    // 关闭代办任务dialog事件
    closeDialogTask () {
      this.$refs.task.resetFields()
      this.task = {
        taskId:0,
        taskDescribe:'',
        taskContactName:'',
        taskFinishDate:'',
        taskTime:null,
        taskPriority:'',
        taskStatus:'',
        taskCreateDate:'',
        taskIs:'',
        opportunityByOppId:'',
        customerByCustomerId:'',
        employeeByEmpId:'',
        employeeByExeEmpId:{}
      }
    },
    // 新增、修改代办任务
    saveTask () {
      // 状态
      this.task.taskIs = 1
      if (this.task.taskId === 0){
        this.task.taskCreateDate = this.addDate()
        this.task.employeeByEmpId = this.emp
      }
      this.$refs.task.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-task',
            {
              taskId:this.task.taskId,
              taskDescribe:this.task.taskDescribe,
              taskContactName:this.task.taskContactName,
              taskFinishDate:this.task.taskFinishDate,
              taskTime:this.task.taskTime,
              taskPriority:this.task.taskPriority,
              taskStatus:this.task.taskStatus,
              taskCreateDate:this.task.taskCreateDate,
              taskIs:this.task.taskIs,
              opportunityByOppId:this.task.opportunityByOppId,
              customerByCustomerId:this.task.customerByCustomerId,
              employeeByEmpId:this.task.employeeByEmpId,
              employeeByExeEmpId:this.task.employeeByExeEmpId,
              chatRecordsByQuotationId:[{
                chatRecordId: 0,
                chatRecordContent: '新建待办任务',
                chatRecordDate:null,
                employeeByEmpId:this.emp,
                taskByTaskId:null
              }]
            })
            .then(v => {
              // 1、刷新数据
              this.findTask()
              this.findAction()
              // 2、关闭弹框
              this.dialogTask = false
              this.$message({
                message: '已保存',
                type: 'success'
              });
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 删除代办任务提示
    handleDeleteTask () {
      this.$confirm('此操作将永久删除待办任务, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteTask()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除代办任务
    deleteTask (){
      this.$axios.post('http://localhost:8088/delete-task',
        this.qs.stringify({taskId: this.task.taskId}))
        .then(v => {
          this.findTask()
          this.findAction()
          this.dialogTask = false
        })
        .catch(function (v) {})
    },
    // 查询记录
    findAction(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/task-action-opp-list',{
        params:{
          oppId:oppId
        }
      })
        .then(v => {
          this.actionList = v.data
        })
        .catch(function (v) {})
    },
    // 记录数据回显
    openAct(val){
      this.dialogAct = true;
      this.action.taskId = val.taskId
      this.action.employeeByExeEmpId = val.employeeByExeEmpId
      this.action.taskDescribe = val.taskDescribe
      this.action.taskContactName = val.taskContactName
      this.action.taskFinishDate = val.taskFinishDate
      this.action.taskClassify = val.taskClassify
      this.action.customerByCustomerId = val.customerByCustomerId
      this.action.employeeByEmpId = val.employeeByEmpId
      this.action.opportunityByOppId = this.opportunity
    },
    // 打开记录dialog事件
    openDialogAct () {
      if (this.action.taskId === 0){
        this.action.customerByCustomerId = this.opportunity.customerByCustomerId
        this.action.employeeByExeEmpId = this.emp
        this.action.opportunityByOppId = this.opportunity
        this.action.taskFinishDate = this.addDate()
      }
    },
    // 关闭记录dialog事件
    closeDialogAct () {
      this.$refs.act.resetFields()
      this.action = {
        taskId:0,
        taskDescribe:'',
        taskContactName:'',
        taskFinishDate:'',
        taskClassify:'',
        taskIs:'',
        opportunityByOppId:'',
        customerByCustomerId:'',
        employeeByEmpId:'',
        employeeByExeEmpId:{}
      }
    },
    // 新增、修改记录
    saveAction () {
      // 状态
      this.action.taskIs = 2
      if (this.action.taskId == 0){
        this.action.employeeByEmpId = this.emp
      }
      this.$refs.act.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-action',
            {
              taskId:this.action.taskId,
              taskDescribe:this.action.taskDescribe,
              employeeByExeEmpId:this.action.employeeByExeEmpId,
              taskContactName:this.action.taskContactName,
              taskFinishDate:this.action.taskFinishDate,
              taskClassify:this.action.taskClassify,
              taskIs:this.action.taskIs,
              opportunityByOppId:this.action.opportunityByOppId,
              customerByCustomerId:this.action.customerByCustomerId,
              employeeByEmpId:this.action.employeeByEmpId
            })
            .then(v => {
              // 1、刷新数据
              this.findAction()
              // 2、关闭弹框
              this.dialogAct = false
              this.$message({
                message: '已保存',
                type: 'success'
              });
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 删除记录提示
    handleDeleteAct () {
      this.$confirm('此操作将永久删除行动记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteAct()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除记录
    deleteAct (){
      this.$axios.post('http://localhost:8088/delete-task',
        this.qs.stringify({taskId: this.action.taskId}))
        .then(v => {
          this.findAction()
          this.dialogAct = false
        })
        .catch(function (v) {})
    },
    // 查询出差
    findBusiness(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/business-opp-list', {
        params: {
          oppId:oppId
        }
      })
        .then(v => {
          this.businessList = v.data
        })
        .catch(function (v) {})
    },
    // 打开出差dialog事件
    openDialogBus () {
      if (this.business.businessId === 0){
        this.business.employeeByEmpId = this.emp
        this.business.customerByCustomerId = this.opportunity.customerByCustomerId
        this.business.opportunityByOppId = this.opportunity
        this.business.businessClassify = 1
      }
    },
    // 关闭出差dialog事件
    closeDialogBus () {
      this.$refs.bus.resetFields()
      this.business = {
        businessId: 0,
        businessTheme: '',
        businessStartDate: '',
        businessEndDate: '',
        businessDestination: '',
        businessVehicle: '',
        businessMoney: '',
        businessClassify: '',
        businessRemarks: '',
        businessPeer: '',
        businessAppStatus: 0,
        customerByCustomerId: '',
        employeeByEmpId: '',
        employeeByAppEmpId: null,
        opportunityByOppId: null
      }
    },
    // 新增、修改出差
    addBusiness () {
      this.$refs.bus.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-business',this.business)
            .then(v => {
              // 1、刷新数据
              this.findBusiness()
              // 2、关闭弹框
              this.dialogBus = false
              this.$message({
                type: 'success',
                message: '已保存'
              })
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 查询详细需求
    findDemand(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/demand-opp-list', {
        params: {
          oppId: oppId
        }
      })
        .then(v => {
          this.demandList = v.data
        })
        .catch(function (v) {})
    },
    // 详细需求数据回显
    openDem(val){
      this.dialogDem = true
      this.demand.demandId = val.demandId
      this.demand.demandTheme = val.demandTheme
      this.demand.demandOffer = val.demandOffer
      this.demand.demandDate = val.demandDate
      this.demand.demandSign = val.demandSign
      this.demand.demandContent = val.demandContent
      this.demand.opportunityByOppId = val.opportunityByOppId
      this.demand.customerByCustomerId = val.customerByCustomerId
    },
    // 打开demDialog事件
    openDialogDem () {
      if (this.demand.demandId === 0){
        this.demand.demandDate = this.addDate()
        this.demand.customerByCustomerId = this.opportunity.customerByCustomerId
        this.demand.opportunityByOppId = this.opportunity
      }
    },
    // 关闭demDialog事件
    closeDialogDem () {
      this.$refs.dem.resetFields()
      this.demand= {
        demandId: 0,
        demandTheme: '',
        demandOffer: '',
        demandDate: '',
        demandSign: '',
        demandContent: '',
        opportunityByOppId:'',
        customerByCustomerId:{}
      }
    },
    // 新增、修改详细需求
    addDemand(){
      this.$refs.dem.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-demand',this.demand)
            .then(v => {
              // 1、刷新数据
              this.findDemand()
              // 2、关闭弹框
              this.dialogDem = false
              this.$message({
                message: '已保存',
                type: 'success'
              });
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });

    },
    // 删除详细需求提示
    handleDeleteDem () {
      this.$confirm('此操作将永久删除详细需求, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteDem()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除详细需求
    deleteDem(){
      this.$axios.post('http://localhost:8088/delete-demand',
        this.qs.stringify({demandId: this.demand.demandId}))
        .then(v => {
          // 1、刷新数据
          this.initData()
          this.findDemand()
          this.dialogDem = false
        })
        .catch(function (v) {})
    },
    // 查询报价
    findQuotation () {
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/quo-opp-list', {
        params: {
          oppId:oppId
        }
      })
        .then(v => {
          this.quotationList = v.data
        })
        .catch(function (v) {})
    },
    // 查询报价明细
    findDetail(quoId){
      this.$axios.get('http://localhost:8088/quo-detail-list', {
        params:{
          quoId : quoId
        }
      })
        .then(v => {
          this.detailList = v.data
        })
        .catch(function (v) {})
    },
    // 查询报价单审批记录集合
    findAppRecord(quoId){
      this.$axios.get('http://localhost:8088/app-record-quo-list', {
        params:{
          quoId : quoId
        }
      })
        .then(v => {
          this.approvalRecordList = v.data
        })
        .catch(function (v) {})
    },
    // 报价数据回显
    openQuo (val) {
      this.dialogQuo = true
      this.quotation.quotationId = val.quotationId
      this.quotation.quotationTheme = val.quotationTheme
      this.quotation.quotationNo = val.quotationNo
      this.quotation.quotationStatus = val.quotationStatus
      this.quotation.quotationClassify = val.quotationClassify
      this.quotation.quotationDate = val.quotationDate
      this.quotation.quotationPrice = val.quotationPrice
      this.quotation.quotationDelivery = val.quotationDelivery
      this.quotation.quotationPayment = val.quotationPayment
      this.quotation.quotationPackage = val.quotationPackage
      this.quotation.quotationRemarks = val.quotationRemarks
      this.quotation.quotationContactName = val.quotationContactName
      this.quotation.employeeByEmpId = val.employeeByEmpId
      this.quotation.quotationAppStatus = val.quotationAppStatus
      this.quotation.employeeByAppEmpId = val.employeeByAppEmpId
      this.quotation.opportunityByOppId = val.opportunityByOppId
      this.quotation.customerByCustomerId = val.customerByCustomerId
      this.findDetail(val.quotationId)
      this.findAppRecord(val.quotationId)
    },
    // 打开报价dialog事件
    openDialogQuo () {
      if (this.quotation.quotationId === 0){
        this.quotation.customerByCustomerId = this.opportunity.customerByCustomerId
        this.quotation.employeeByEmpId = this.emp
        this.quotation.opportunityByOppId = this.opportunity
        this.quotation.quotationStatus = 1
        this.quotation.quotationDate = this.addDate()
      }
    },
    // 关闭报价dialog事件
    closeDialogQuo () {
      this.$refs.quo.resetFields()
      this.quotation = {
        quotationId: 0,
        quotationTheme: '',
        quotationNo: '',
        quotationStatus: '',
        quotationClassify: '',
        quotationDate: '',
        quotationPrice: '',
        quotationDelivery: '',
        quotationPayment: '',
        quotationPackage: '',
        quotationRemarks: '',
        quotationContactName: '',
        quotationAppStatus: 0,
        opportunityByOppId: '',
        customerByCustomerId: '',
        employeeByEmpId:'',
        employeeByAppEmpId:null
      }
      this.detailList = []
      this.approvalRecordList = []
      this.contactList = []
    },
    // 新增、修改报价
    addQuotation () {
      if(this.quotation.quotationId == 0){
        this.quotation.quotationNo = this.quoNo()
      }
      this.$refs.quo.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-quotation',
            {
              quotationId:this.quotation.quotationId,
              quotationTheme:this.quotation.quotationTheme,
              quotationNo:this.quotation.quotationNo,
              quotationStatus:this.quotation.quotationStatus,
              quotationClassify:this.quotation.quotationClassify,
              quotationDate:this.quotation.quotationDate,
              quotationPrice:this.quotation.quotationPrice,
              quotationDelivery:this.quotation.quotationDelivery,
              quotationPayment:this.quotation.quotationPayment,
              quotationPackage:this.quotation.quotationPackage,
              quotationRemarks:this.quotation.quotationRemarks,
              quotationContactName:this.quotation.quotationContactName,
              employeeByEmpId: this.quotation.employeeByEmpId,
              quotationAppStatus:this.quotation.quotationAppStatus,
              employeeByAppEmpId: this.quotation.employeeByAppEmpId,
              opportunity:this.quotation.opportunityByOppId,
              customerByCustomerId:this.quotation.customerByCustomerId,
              details:this.detailList
            })
            .then(v => {
              // 1、刷新数据
              this.findQuotation()
              // 2、关闭弹框
              this.dialogQuo = false
              this.$message({
                message: '已保存',
                type: 'success'
              });
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 点击编辑详单跳转到报价视图
    openPro(val){
      this.$router.push({path:'/quotationview',query: {quoId: val}});
    },
    // 删除报价提示
    handleDeleteQuo () {
      this.$confirm('此操作将永久删除报价, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteQuo()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除报价
    deleteQuo(){
      this.$axios.post('http://localhost:8088/delete-quotation',
        this.qs.stringify({quoId: this.quotation.quotationId}))
        .then(v => {
          this.findQuotation()
          this.dialogQuo = false
        })
        .catch(function (v) {})
    },
    // 生成订单提示
    repealOrder(val){
      if (val.quotationAppStatus === 2){
        this.$confirm('此操作将生成订单, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.saveOrderJudge(val)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消生成'
          })
        })
      }else {
        this.$message({
          type: 'info',
          message: '当前报价单未审批通过，不允许转成订单。'
        })
      }
    },
    // 生成合同订单操作
    saveOrderJudge(val){
      // 修改机会
      this.saveOpportunity()
      // 修改报价
      this.quotation = val
      this.quotation.quotationStatus = 3
      this.findOrderDetail(val.quotationId)
    },
    // 查询报价明细
    findOrderDetail(quoId){
      this.$axios.get('http://localhost:8088/quo-detail-list', {
        params:{
          quoId : quoId
        }
      })
        .then(v => {
          this.detailList = v.data
          this.saveQuotation()
          this.saveOrder()
        })
        .catch(function (v) {})
    },
    // 合同订单axais
    saveOrder(){
      this.$axios.post('http://localhost:8088/save-contract',
        {
          contractId:0,
          contractTheme:'订单:'+this.quotation.quotationTheme,
          contractNo:this.contractNo(),
          contractTotalAmount:this.quotation.quotationPrice,
          contractStartTime:this.addDate(),
          contractBackAmount:0,
          contractStatus:1,
          contractAppStatus: 0,
          customerByCustomerId:this.quotation.customerByCustomerId,
          opportunity: this.quotation.opportunityByOppId,
          employeeByEmpId:this.quotation.employeeByEmpId,
          details:this.detailList
        })
        .then(v => {
          this.$router.push({path: '/contractview', query: {contractId: v.data}});
          this.$message({
            message: '请补全合同订单信息',
            type: 'success'
          });
        })
        .catch(function (v) {})

    },
    saveQuotation(){
      this.$axios.post('http://localhost:8088/save-quotation',
        {
          quotationId:this.quotation.quotationId,
          quotationTheme:this.quotation.quotationTheme,
          quotationNo:this.quotation.quotationNo,
          quotationStatus:this.quotation.quotationStatus,
          quotationClassify:this.quotation.quotationClassify,
          quotationDate:this.quotation.quotationDate,
          quotationPrice:this.quotation.quotationPrice,
          quotationDelivery:this.quotation.quotationDelivery,
          quotationPayment:this.quotation.quotationPayment,
          quotationPackage:this.quotation.quotationPackage,
          quotationRemarks:this.quotation.quotationRemarks,
          quotationContactName:this.quotation.quotationContactName,
          employeeByEmpId: this.quotation.employeeByEmpId,
          quotationAppStatus:this.quotation.quotationAppStatus,
          employeeByAppEmpId: this.quotation.employeeByAppEmpId,
          opportunity:this.quotation.opportunityByOppId,
          customerByCustomerId:this.quotation.customerByCustomerId,
          details:this.detailList
        })
        .then(v => {
        })
        .catch(function (v) {})
    },
    saveOpportunity(){
      this.opportunity.oppStatus = 2
      this.opportunity.oppStage = 7
      this.opportunity.oppPossibility = 11
      this.opportunity.oppUpdateDate = this.addDate()
      this.saveTraceSuccess()
      this.$axios.post('http://localhost:8088/save-opportunity',this.opportunity)
        .then(v => {
        })
        .catch(function (v) {})
    },
    saveTraceSuccess(){
      this.trace.traceDate = this.addDate()
      this.trace.traceStage = '合同签约'
      this.trace.tracePrincipal = '100%'
      this.trace.traceSignDate = this.opportunity.oppSignDate
      this.trace.traceExpectSum = this.opportunity.oppExpectSum
      this.trace.tracePriRemark = this.emp.empName+' - 生成合同订单'
      this.trace.opportunityByOppId = this.opportunity
      this.$axios.post('http://localhost:8088/save-trace',this.trace)
        .then(v => {
        })
        .catch(function (v) {})
    },
    // 导出PDF
    printPdf(val){
      this.$router.push({path: '/printquotation', query: {quoId: val}});
    },
    // 查询解决方案
    findSolution(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/solution-opp-list', {
        params: {
          oppId: oppId
        }
      })
        .then(v => {
          this.solutionList = v.data
        })
        .catch(function (v) {})
    },
    // 解决方案数据回显
    openSol(val){
      this.dialogSol = true
      this.solution.solutionId = val.solutionId
      this.solution.solutionTheme = val.solutionTheme
      this.solution.solutionDate = val.solutionDate
      this.solution.solutionFeedback = val.solutionFeedback
      this.solution.solutionContent = val.solutionContent
      this.solution.opportunityByOppId = val.opportunityByOppId
      this.solution.customerByCustomerId = val.customerByCustomerId
    },
    // 打开解决方案dialog事件
    openDialogSol () {
      if (this.solution.solutionId === 0){
        this.solution.customerByCustomerId = this.opportunity.customerByCustomerId
        this.solution.opportunityByOppId = this.opportunity
        this.solution.solutionDate = this.addDate()
      }
    },
    // 关闭解决方案dialog事件
    closeDialogSol () {
      this.$refs.sol.resetFields()
      this.solution = {
        solutionId: 0,
        solutionTheme: '',
        solutionDate: '',
        solutionFeedback: '',
        solutionContent: '',
        opportunityByOppId: '',
        customerByCustomerId:{}
      }
    },
    // 新增、修改解决方案
    addSolution () {
      this.$refs.sol.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-solution',this.solution)
            .then(v => {
              // 1、刷新数据
              this.findSolution()
              // 2、关闭弹框
              this.dialogSol = false
              this.$message({
                message: '已保存',
                type: 'success'
              });
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 删除解决方案提示
    handleDeleteSol () {
      this.$confirm('此操作将永久删除该解决方案, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteSol()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除解决方案
    deleteSol(){
      this.$axios.post('http://localhost:8088/delete-solution',
        this.qs.stringify({solutionId: this.solution.solutionId}))
        .then(v => {
          // 1、刷新数据
          this.findSolution()
          this.dialogSol = false
        })
        .catch(function (v) {})
    },
    // 查询竞争
    findCompetitor(){
      let oppId = this.$route.query.oppId
      this.$axios.get('http://localhost:8088/competitor-opp-list', {
        params: {
          oppId: oppId
        }
      })
        .then(v => {
          this.competitorList = v.data
        })
        .catch(function (v) {})
    },
    // 竞争数据回显
    openCom(val){
      this.dialogCom = true
      this.competitor.competitorId = val.competitorId
      this.competitor.competitorName = val.competitorName
      this.competitor.competitorPrice = val.competitorPrice
      this.competitor.competitorCapacity = val.competitorCapacity
      this.competitor.competitorProduct = val.competitorProduct
      this.competitor.competitorStrengths = val.competitorStrengths
      this.competitor.competitorWeaknesses = val.competitorWeaknesses
      this.competitor.competitorStrategy = val.competitorStrategy
      this.competitor.competitorRemarks = val.competitorRemarks
      this.competitor.opportunityByOppId = val.opportunityByOppId
      this.competitor.customerByCustomerId = val.customerByCustomerId
    },
    // 打开竞争dialog事件
    openDialogCom () {
      if (this.competitor.competitorId === 0){
        this.competitor.customerByCustomerId = this.opportunity.customerByCustomerId
        this.competitor.opportunityByOppId = this.opportunity
      }
    },
    // 关闭dialog事件
    closeDialogCom  () {
      this.$refs.com.resetFields()
      this.competitor = {
        competitorId: 0,
        competitorName: '',
        competitorPrice: '',
        competitorCapacity: '',
        competitorProduct: '',
        competitorStrengths: '',
        competitorWeaknesses: '',
        competitorStrategy: '',
        competitorRemarks: '',
        opportunityByOppId: '',
        customerByCustomerId:{}
      }
    },
    // 新增、修改
    addCompetitor () {
      // 状态
      this.$refs.com.validate((valid) => {
        if (valid) {
          this.$axios.post('http://localhost:8088/save-competitor',this.competitor)
            .then(v => {
              this.findCompetitor()
              this.dialogCom = false
              this.$message({
                message: '已保存',
                type: 'success'
              });
            })
            .catch(function (v) {})
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 删除提示
    handleDeleteCom () {
      this.$confirm('此操作将永久删除该竞争, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteCom()
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 删除axios
    deleteCom(){
      this.$axios.post('http://localhost:8088/delete-competitor',
        this.qs.stringify({competitorId: this.competitor.competitorId}))
        .then(v => {
          this.findCompetitor()
          this.dialogCom = false
        })
        .catch(function (v) {})
    },
    //获取当前日期
    addDate() {
      var date = new Date();
      var seperator1 = "-";
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
      }
      var currentdate = year + seperator1 + month + seperator1 + strDate;
      return currentdate;
    },
    // 报价单号
    quoNo() {
      var quoNo = "";
      for (var i = 0; i < 4; i++) //j位随机数，用以加在时间戳后面。
      {
        quoNo += Math.floor(Math.random() * 10);
      }
      quoNo = 'BJ' + this.addDateNum() + quoNo;
      return quoNo;
    },
    // 合同订单号
    contractNo() {
      var contractNo = "";
      for (var i = 0; i < 4; i++) //j位随机数，用以加在时间戳后面。
      {
        contractNo += Math.floor(Math.random() * 10);
      }
      contractNo = 'HT' + this.addDateNum() + contractNo;
      return contractNo;
    },
    // 获取当前日期20200206
    addDateNum () {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
      }
      var currentdate = year  + month  + strDate;
      return currentdate;
    },
  },
  created: function () {
    this.loginEmp()
    this.initData()
    this.findTrace()
    this.findTask()
    this.findAction()
    this.findBusiness()
    this.findDemand()
    this.findQuotation()
    this.findSolution()
    this.findCompetitor()
  },
    filters: {
      formatDate: function(time) {
        if(time!=null&&time!="")
        {
          var date = new Date(time);
          return formatTimeToStr(date, "yyyy-MM-dd hh:mm");
        }else{
          return "";
        }
      },
      formatDateJudge: function(time) {
        if(time != null && time != "")
        {
          let date = new Date(time);
          let currentDate = new Date()
          let seperator1 = "-";
          let month = currentDate.getMonth() + 1<10? "0"+(currentDate.getMonth() + 1):currentDate.getMonth() + 1;
          let strDate = currentDate.getDate()<10? "0" + currentDate.getDate():currentDate.getDate();
          let today = currentDate.getFullYear() + seperator1  + month  + seperator1  + strDate
          let todayTime = new Date(today)
          let yesterday = todayTime.setDate(todayTime.getDate() - 1)
          let beforeYesterday = todayTime.setDate(todayTime.getDate() - 1)
          let tomorrow = todayTime.setDate(todayTime.getDate() + 3)
          let afterTomorrow = todayTime.setDate(todayTime.getDate() + 1)
          todayTime.setDate(todayTime.getDate() - 2)
          if (date.getTime() === todayTime.getTime()){
            return '今天'
          }else if (date.getTime() ===  yesterday){
            return '昨天'
          }else if (date.getTime() ===  beforeYesterday){
            return '前天'
          }else if (date.getTime() ===  tomorrow){
            return '明天'
          }else if (date.getTime() ===  afterTomorrow){
            return '后天'
          }else {
            return time
          }
        }else{
          return "";
        }
      }
    }
}
</script>

<style>
</style>
